<%@page import="com.google.appengine.api.datastore.KeyFactory"%>
<%@page import="java.util.List"%>
<%@page import="br.ufrn.cloud.gae.teamgae.model.Time"%>
<%@page import="javax.jdo.Query"%>
<%@page import="br.ufrn.cloud.gae.teamgae.jdo.PersistenceManagerGAE"%>
<%@page import="javax.jdo.PersistenceManager"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/time.js"></script>
<script type="text/javascript" src="js/js/jquery-ui-1.8.19.custom.min.js"></script>
<link type="text/css" href="js/css/sunny/jquery-ui-1.8.19.custom.css" rel="stylesheet"/>  
<title>Times 2.0</title>




</head>
<body>

<button id="criartime">Criar Time</button>
<table class="ui-widget ui-widget-content" id="tabelatimes">
<%

	PersistenceManager pm=PersistenceManagerGAE.getPersistenceManagerFactory().getPersistenceManager();
	
	Query query=pm.newQuery(Time.class);
	
	List<Time> times=(List<Time>)query.execute();
	
	%>
<thead>
<tr class="ui-widget-header">
<td>Time</td>
<td>Estado</td>
<td>Operações</td>
</tr>
</thead>
<tbody>
<%
	for(Time time:times){
		
	
%>
<tr id="tr<%=KeyFactory.keyToString(time.getKey())%>">
<td><a href="listaJogadores.jsp?key=<%=KeyFactory.keyToString(time.getKey())%>" ><%=time.getNome() %></a></td>
<td><%=time.getEstado() %></td>
<td><a href="#" class="alterar" id="alt<%=KeyFactory.keyToString(time.getKey()) %>">Alterar</a> <a class="excluir" href="#" id="exc<%=KeyFactory.keyToString(time.getKey()) %>">Excluir</a></td>
</tr>

<%}
	pm.close();
%>
</tbody>
</table>

<div id="formtime" title="Cadastrar Time">

<form>
<fieldset>
<legend>Cadastro</legend>
<label for="nome">Nome:</label>
<input type="text" name="nome" id="nome" class="text ui-widget-content ui-cornerall"/>
<label for="estado">Estado:</label>
<input type="text" name="estado" id="estado" class="text ui-widget-content ui-cornerall"/>
<input type="hidden" id="operacao" name="operacao"/>
<input type="hidden" id="timekey" name="timekey"/>
</fieldset>
</form>

</div>

</body>
</html>